package com.zsh.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class RespondIOServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //方法1,服务器 响应头分别设置字符集
        //服务器 设置字符集
        //response.setCharacterEncoding("UTF-8");

        //响应头 设置字符集
        //response.setHeader("Content-Type","text/html;charset=UTF-8");

        //方法2 一次设置两端,必须在流获取之前设置
        response.setContentType("text/html;charset=UTF-8");


        PrintWriter writer = response.getWriter();



        writer.write("responsea阿松大");
        writer.println("12312312阿斯顿撒");
//        response.getOutputStream();
    }
}
